import scrapy
from www58pic.items import Www58PicItem
from scrapy.http import Request


class MySpiderSpider(scrapy.Spider):
    name = 'my_spider'
    allowed_domains = ['www.58pic.com']
    start_urls = ['https://www.58pic.com/tupian/gaoqingtupian.html']

    def parse(self, response):
        item = Www58PicItem()
        item['picurl'] = response.xpath('//div[@class="qtw-card normalCard"]//img/@data-original').extract()
        item['title'] = response.xpath('//div[@class="qtw-card normalCard"]//img/@title').extract()
        yield item

        for i in range(11,13):
            nexturl = "https://www.58pic.com/tupian/gaoqingtupian-809-0-"+str(i)+".html"
            yield Request(nexturl,callback=self.parse)
            #<img src="//preview.qiantucdn.com/58pic/37/15/07/50H58PICwTNv6imRxsGZT_origin_PIC2018.jpg!w1024_new_small" class="show-area-pic loading_space_img" alt="高清图片格桑花" title="高清图片格桑花" style="position: relative;top: 50%;transform: translate(0%, -50%);width: 100%;transition: none;">
            #<img class//preview.qiantucdn.com/58pic/37/14/64/51r58PICf98j5epPskt7c_origin_PIC2018.jpg!qt324new_nowater" src="//preview.qiantucdn.com/58pic/37/14/64/51r58PICf98j5epPskt7c_origin_PIC2018.jpg!qt324new_nowater" alt="葡萄摆拍素材<i>高</i><i>清</i><i>图</i><i>片</i>" title="葡萄摆拍素材<i>高</i><i>清</i><i>图</i><i>片</i>" style="display: block;">
